import { http } from "@/utils/http";
import { BaseRequest, ObjectKeyValue, Result } from "@/api/index";

export type ProcessDefineVO = {
  id: string;
  processName: string;
  processApi: string;
  businessApi: string;
  businessType: string;
  deployState: string;
  flowableProcessDefineKey: string;
  flowableDeploymentId: string;
  bpmn: string;
};

export type FlowableProcessDefineDTO = {
  id: string;
  processName: string;
  processApi: string;
  businessApi: string;
  businessType: string;
};

export const processDefinePageList = (data: BaseRequest) => {
  return http.request<Result<Array<ProcessDefineVO>>>(
    http.POST,
    "/processDefine/pageList",
    { data }
  );
};

export const processDefineBaseSave = (data: FlowableProcessDefineDTO) => {
  return http.request<Result<null>>(http.POST, "/processDefine/baseSave", {
    data
  });
};

export const processDefineBaseUpdate = (data: FlowableProcessDefineDTO) => {
  return http.request<Result<null>>(http.POST, "/processDefine/baseUpdate", {
    data
  });
};

export const processDefineBaseInfo = (params: { id: string }) => {
  return http.request<Result<FlowableProcessDefineDTO>>(
    http.GET,
    "/processDefine/baseInfo",
    {
      params
    }
  );
};

export const processDefineBaseDelete = (params: { id: string }) => {
  return http.request<Result<null>>(http.DELETE, "/processDefine/baseDelete", {
    params
  });
};

export const processDefineComplexInfo = (params: { id: string }) => {
  return http.request<Result<ProcessDefineVO>>(
    http.GET,
    "/processDefine/complexInfo",
    {
      params
    }
  );
};

export const processDefineGetVO = () => {
  return http.request<Result<Array<ObjectKeyValue>>>(
    http.GET,
    "/processDefine/getVO"
  );
};
